#include "timer.hpp"
#include "iostream"
#include "../os/linux.hpp"


void elapsedTimer::start(){
    _start_counter = Linux::elapsed_counter();
}


void elapsedTimer::stop(){
    _counter = Linux::elapsed_counter() - _start_counter;
}

double elapsedTimer::seconds(){
    double count = (double)_counter;
    double freq = (double)(1000000000);
    return _counter/freq;
}

TraceTime::TraceTime(const char* title){
    std::cout << title << "时间统计开始..." << std::endl;
    t.start();
}

TraceTime::~TraceTime(){
    t.stop();
    std::cout << "时间统计结束，耗时" << t.seconds() << std::endl;
}